package com.rss;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import persist.article.Article;

public class RssAction{

    public void testBuildObject(List one,List two) {
        try {
            RssBuilder builder = new RssBuilder();
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
            // 循环遍历数据库记录生成Rss中的Item项
            for(int i=0;i<one.size();i++){
                Article rs=(Article)one.get(i);
                ChannelEItem item = new ChannelEItem();
                item.setTitle(rs.getTitle());
                item.setLink("ArticleDetail.action?id="+rs.getId());
                item.setDescription(rs.getContent());
                item.setPubDate(format.parse(rs.getTime()));
                item.setCategory("我的文章");
                item.setAuthor(rs.getAuthor());
                item.setEnclosure("www.xxx.cn");
                builder.createItems(item);
            }

            // 建立Rss的Channel信息
            builder.createChannel("个人博客","www.xxx.cn", "个人博客","zh-cn", new Date(), "个人博客");

            builder.buildChannel(System.getProperty("REAL_PATH") + "\\rss.xml");
        } catch (Exception e) {
            System.out.println("this is in error");
            System.out.println(e.getMessage());
        }
    }

}
